import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, IStudentUnion } from "./types";

/* 查询学生会列表 */
export function getPageStudentUnionAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<IStudentUnion[]>> {
  return request({
    url: "/studentUnion/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询学生会对象 */
export function getFormStudentUnionAPI(
  id: number
): AxiosPromise<IStudentUnion> {
  return request({
    url: `/studentUnion/${id}/form`,
    method: "get",
  });
}

/**
 * 添加学生会
 *
 * @param data
 */
export function addStudentUnionAPI(data: any) {
  return request({
    url: "/studentUnion",
    method: "post",
    data: data,
  });
}

/**
 * 修改学生会
 *
 * @param id
 * @param data
 */
export function updateStudentUnionAPI(id: number, data: IStudentUnion) {
  return request({
    url: "/studentUnion/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除学生会
 *
 * @param ids
 */
export function deleteStudentUnionAPI(ids: number) {
  return request({
    url: "/studentUnion/" + ids,
    method: "delete",
  });
}
